#!/bin/bash

read -p "please input username prefix:" USER
read -p "the number of new users:" NUM
for i in $(seq -w $NUM)
do
	if id ${USER}$i &>/dev/null
	then 
		echo -e "\e[31mthe ${USER}$i is already exists\e[0m"
	else
		useradd ${USER}$i && echo -e "\e[35m${USER}$i has been creatred\e[0m"
		read -p "please input passwd:" u_PWD
		echo "$u_PWD"|passwd ${USER}$i --stdin &>/dev/null
		echo -e "\e[34m${USER}${i}'s password has been setted!\e[0m"
	fi
done
